namespace go admin_product
include "error_code.thrift"
include "common.thrift"

struct Product {
    1: i64 ID(api.body="id")
    2: string Name(api.body="name")
    3: string SliderImage(api.body="slider_image")
    4: string ShortInfo(api.body="short_info")
    5: i64 CategoryID(api.body="category_id")
    8: string UnitName(api.body="unit_name")
    9: i64 Sort(api.body="sort")
    12: common.ProductStatus Status(api.body="status")
    13: string Description(api.body="description")
    17: common.ProductSpecType SpecType(api.body="spec_type")
    18: i64 CreateTime(api.body="create_time")
    19: string CategoryName(api.body="category_name")
    20: string Image(api.body="image")
    21: double Price(api.body="price")
}

struct CreateProductRequest {
    2: string Name (api.body='name')
}

struct CreateProductResponse {
    1: error_code.ErrorCode Code (api.body='code')
}

struct GetProductInfoRequest {
    2: i64 ID (api.body='id')
}

struct GetProductInfoResponse {
    1: error_code.ErrorCode Code (api.body='code')
    2: Product Data(api.body='data')
}

struct GetProductListRequest {
    1: i64 Page = 1 (api.query="page");
    2: i64 Size = 20 (api.query="size");
    3: optional common.ProductStatus Status (api.query="status");
    4: optional i64 CategoryID (api.query="category_id");
}

struct GetProductListResponse {
    1: error_code.ErrorCode Code (api.body='code')
    2: list<Product> Data (api.body='data')
    4: i64 Total (api.body='total')
}

struct DeleteProductRequest {
    1: list<i64> IDs (api.body="ids")
}

struct DeleteProductResponse {
    1: error_code.ErrorCode Code (api.body='code')
}

struct UpdateProductRequest {
    1: i64 ID (api.body="id")
    2: optional string Name (api.body='name')
}

struct UpdateProductResponse {
    1: error_code.ErrorCode Code (api.body='code')
}
